#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;


int main(){
	string a,b;
	cin>>a>>b;
	int al=a.length(),bl=b.length();
	int dp[bl+1][al+1];
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<=al;i++)
		dp[0][i] = i;
	for(int i=0;i<=bl;i++)
		dp[i][0] = i;
	for(int i=1;i<=bl;i++){
		for(int j=1;j<=al;j++){
				dp[i][j] = min(dp[i-1][j]+1,min(dp[i][j-1]+1,dp[i-1][j-1]+1));
			if(a[j-1] == b[i-1])
				dp[i][j] = min(dp[i][j],dp[i-1][j-1]);
//			cout<<dp[i][j]<<" ";
		}
//		cout<<endl;
	}
	cout<<dp[bl][al];
	return 0;
}
